# -*- coding: utf-8 -*-
# 2022/5/30 13:30
# Author :jiangdeping
import MySQLdb


MySqlConfig = {
"host": "10.80.1.80",
"port": 3356,
"user": "root",
"password": "dbsa123!@#",
"db": "cqzh_jdyw_test",
"charset": "utf8",# 数据库连接编码'
}

def MySql_stats(sql):
    conn = MySQLdb.Connect(**MySqlConfig)
    cur = conn.cursor()
    cur.execute(sql)
    result = cur.fetchall()
    cur.close()
    conn.close()
    return result
def falutrepair():
    sql="""
       select total.total as 总故障数,completeCount.completecount as 已完成故障数,CONCAT(CONVERT(completeCount.completecount*100/total.total,DECIMAL(18,2)),'%')
 as 完成率,(total.total-completeCount.completecount) 未完成数 from
(select count(*)  total from fault_report where status not in (1,-1) and stateId=1 and roadSectionId in('124','125','126'))as total,
(select count(*) completecount from fault_report where status=12 and stateId=1 and roadSectionId in('124','125','126')) as completeCount
    """
    result=MySql_stats(sql)
    totalcount=result[0][0]
    falutcount=result[0][1]
    return totalcount,falutcount

